<template>
  <div class="film-item">
    <router-link :to="'/movie/' + item.id">
      <img :src="item.poster.thumbnail" alt="">
      <div class="movie-info">
        <div class="film-name">{{item.name}}</div>
        <div class="film-intro">{{item.intro}}</div>
        <div class="count" v-if="item.isNowPlaying">
          <span>{{item.cinemaCount}}</span>
          <span>家影院上映</span>
          <span>{{item.watchCount}}</span>
          <span>人购票</span>
        </div>
        <div class="count" v-else>
            <span>{{item.premiereAt | formatData}}</span>
            <span>上映</span>
        </div>
      </div>
      <div class="buy-right">
        <span class="score" v-if="item.isNowPlaying">{{item.grade}}</span>
        <span v-else>{{item.watchCount | number}}想看</span>
        <div class="buy-btn">
          <button class="button" :class="item.isNowPlaying ? '' : 'blue'">{{item.isNowPlaying ? '购票' : '预售'}}</button>
        </div>
      </div>
    </router-link>
  </div>
</template>

<script>
export default {
  props: ['item'],
  filters: {
    formatData (value) {
      // console.log(value)
      let time = new Date(value)
      let month = time.getMonth() + 1
      let date = time.getDate()
      return `${month}月${date}日`
    },
    number (value) {
      if (value > 10000) return value / 10000 + '万'
      return value
    }
  }
}
</script>
button
<style>
.film-item a {
  display: flex;
  padding: 10px;
  border-bottom: 1px solid #eaeaea;
}
.film-item img {
  width: 65px;
  height: 95px;
}
.film-item .movie-info {
  flex: 1;
  margin-left: 10px;
  padding-top: 5px;
  overflow: hidden;
}
.film-item .movie-info .film-name {
  overflow: hidden;
  padding-right: .1rem;
  color: #333;
  font-size: 16px;
  line-height: 1.35;
  vertical-align: middle;
}
.movie-info .film-intro {
  margin: 15px 0 6px 0;
  color: #666;
  font-size: 14px;
}
.count {
  color: #9a9a9a;
}
.buy-right {
  width: 66px;
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.buy-right span {
  color: #9a9a9a;
}
.buy-right .score {
  color: #cf616a;
  font-size: 14px;
}
.score::after {
  content: '分';
  color: #cf616a;
}
.buy-btn {
  padding-bottom: 10px;
}
.buy-btn .button {
  color: #29cc6d;
  background: transparent;
  border: 1px solid #29cc6d;
  padding: 4px 8px;
  border-radius: 2px;
  outline: none;
}
.buy-btn .blue {
  color: #1b97ff;
  border-color: #1b97ff;
}
</style>

